<%@tag description="page index" pageEncoding="UTF-8"%>
<%@ attribute name="recordCount" type="java.lang.Integer" required="true"%>
<%@ attribute name="pageSize" type="java.lang.Integer" required="true"%>


<%
Integer o = (Integer)jspContext.getAttribute("recordCount");
int recordCount = o.intValue();

o = (Integer)jspContext.getAttribute("pageSize");
int pageSize = o.intValue();



int pageCount = recordCount / pageSize;
if (pageCount * pageSize < recordCount) ++pageCount;
%>

<%
String uri = request.getRequestURI();
String query = request.getQueryString();
String url = "";
String pt = "pg=[0-9]+";

int currentPage = 1;
if (request.getParameter("pg") != null) {
    currentPage = Integer.parseInt(request.getParameter("pg"));
    url = uri + "?" + query;
} else {
    if (query == null) url = uri + "?pg=1";
    else url = uri + "?" + query + "&pg=1";
}
if (currentPage > pageCount) currentPage = pageCount;
int base = ((currentPage - 1) / 10) * 10;
%>
<STYLE TYPE="text/css">
  a.pager { text-decoration: none; color: #A000FF; font-Size:9pt; 
            width:13px; }
  b.pager { width:13px; }
</STYLE>

<% if (base > 0) { %>
    <a class="pager" href="<%= url.replaceAll(pt, "pg=" + base) %>">≪</a>
<% } %>

<% for (int i=1; i<=10; ++i) { %>
  <% int n = base + i; %>
  <% if (n > pageCount) break; %>
  <% if (n == currentPage) { %>
      <b class="pager"><%= currentPage %></b>
  <% } else { %>
      <a class="pager" href='<%= url.replaceAll(pt, "pg=" + n) %>'><%=n%></a>
  <% } %>
<% } %>

<% if (base+11 <= pageCount) { %>
   <a class="pager" href='<%= url.replaceAll(pt, "pg=" + (base+11)) %>'>≫</a>
<% } %>
